<template>
  <div class="lowerhalf">
    <ul>
      <li v-for="(item, index) in list" :key="index">
        <div>
          <span
            class="halfnav-name"
            @click="clickItem(index)"
            :class="{ activehalf: indexs == index }"
            >{{ item.name }} <span class="count"></span>
          </span>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  components: {},
  name: "GameLowerHalf",
  data() {
    return {
      list: [
        { name: "详情", url: "introduce" },
        { name: "评论", url: "comments" },
      ],
      indexs: "",
    };
  },
  created() {
    if (this.$route.path.split("/")[3] == "introduce") {
      this.indexs = 0;
    } else if (this.$route.path.split("/")[3] == "comments") {
      this.indexs = 1;
    }
  },

  methods: {
    clickItem(index) {
      this.indexs = index;
      this.$router.push({
        path: this.list[index].url,
        params: { id: "1" },
      });
    },
  },
};
</script>

<style>
.lowerhalf {
  width: 80%;
  margin: 0 auto;
  margin-top: 0.5rem;
}

.lowerhalf ul {
  width: 100%;
  list-style: none;
  display: flex;
  height: 0.26rem;
  border-bottom: 1px solid rgb(185, 185, 185);
}
.halfnav-name:hover,
.activehalf {
  color: rgb(35, 173, 229);
  border-bottom: 2px solid rgb(35, 173, 229);
}

.halfnav-name {
  display: inline-block;
  font-size: 0.13rem;
  padding-bottom: 0.08rem;
  margin-right: 0.3rem;
  cursor: pointer;
}

.count {
  font-size: 0.08rem;
}
</style>